﻿<controls:MetroWindow x:Class="MovieGallery.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:vm="clr-namespace:MovieGallery.ViewModel"              
        xmlns:model="clr-namespace:MovieGalleryDLL;assembly=MovieGalleryDLL"
        xmlns:local="clr-namespace:MovieGallery"
        mc:Ignorable="d"
        d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
        Title="Movie Gallery"
        Height="600"
        Width="750"
        DataContext="{Binding Main, Source={StaticResource Locator}}" >

    <Window.Resources>
    </Window.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition MaxHeight="40" MinHeight="40"/>
        </Grid.RowDefinitions>

        <TabControl ItemsSource="{Binding Tabs}">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Header}" />
                </DataTemplate>
            </TabControl.ItemTemplate>

            <TabControl.ContentTemplate>
                <DataTemplate>
                    <ItemsControl ItemsSource="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="6,6,6,6">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="MouseLeftButtonUp">
                                            <cmd:EventToCommand Command="{Binding DataContext.MovieLeftButtonUpCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:MetroWindow}}}" CommandParameter="{Binding FilePath}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>

                                    <Image Source="{Binding Path=Image}" Width="200" Height="283" Stretch="Uniform" />
                                    <TextBlock Text="{Binding Title}" />
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </DataTemplate>
            </TabControl.ContentTemplate>
        </TabControl>

        <StackPanel Grid.Row="1" Orientation="Horizontal" >
            <controls:AppBarButton x:Name="AppBar_Settings" Width="40" Height="40" MetroImageSource="{StaticResource appbar_settings}" />
            <controls:AppBarButton x:Name="AppBar_Database" Width="40" Height="40" MetroImageSource="{StaticResource appbar_database}" />
        </StackPanel>

    </Grid>
</controls:MetroWindow>
